public class TestTax {
    public static void main(String[] args) {
        System.out.println("The tax on $50000 is " + tax(50000));    // 9237.5
        System.out.println("The tax on $27500 is " + tax(27500));    // 3767.5
        System.out.println("The tax on $6000 is " + tax(6000));      // 600.0
        System.out.println("The tax on $120000 is " + tax(120000));  // 28227.0
    }
    
    public static double tax(double income) {
        if (income < 7150.0) {
            return income * 0.1;
        }
        else if (income >= 7150.0 && income < 29050.0) {
            return 715.0 + ((income - 7150) * 0.15);
        }
        else if (income >= 29050.0 && income < 70350.0) {
            return 4000.0 + ((income - 29050.0) * 0.25);
        }
        else {
            return 14325.0 + ((income - 70350) * 0.28);
        }
    }
}